package com.dxf.chepter02

/**
 * 步长 range
 *
 *
 */
object T26_for循环步长 {
  def main(args: Array[String]): Unit = {
    for (i <- 1 to 10) {
      println("i=" + i)
    }

    println("=========================================")
    //步长2
    // /** Make a range from `start` until `end` (exclusive) with given step value.
    //   * @note step != 0
    //   */
    //  def apply(start: Int, end: Int, step: Int): Range = new Range(start, end, step)
    for (i <- Range(1, 10, 2)) {
      println("i=" + i)
    }

    println("=========================================")
    //其它方式控制步长

    for(i<-1 to 10 if i %2 ==1){
      println("i=" + i)
    }



  }
}
